package com.goods.feign.fallback;

import com.demo.common.entity.Goods;
import com.demo.common.response.Result;
import com.goods.feign.client.GoodsServiceClient;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * @author why
 * @description 服务降级
 * @date 2025/9/8 11:14
 */
@Component
@Slf4j
public class GoodsServiceClientFallback implements FallbackFactory<GoodsServiceClient> {
    @Override
    public GoodsServiceClient create(Throwable cause) {
        return new GoodsServiceClient() {

            @Override
            public Result getById(Long id) {
                log.error("获取商品信息失败，给出默认配置");
                return Result.success(new Goods());
            }


        };
    }
}
